package
{
	import flash.events.Event;

	public class Slot25Loading extends Slot25Standard
	{
		private var _percent:Number     = 0;
		private var _target:Number      = 0;
		public static const DONE:String = 'DONE';
		public const TICK:Number        = 2 / 100;
		public const WAIT:Number        = 0.5;

		public function set percent(n:Number):void
		{
			_percent = Math.floor(n);
			addTween(this, {target: percent, time: (percent - target) * TICK, transition: 'linear'});
		}

		public function get percent():Number
		{
			return _percent;
		}

		public function set target(n:Number):void
		{
			_target = Math.floor(n);
			clip.oLoading.gotoAndStop(_target);
			clip.oLoading.txtPercent.text = _target + '%';
			if (_target >= 100)
			{
				addCaller(this, {count: 1, time: WAIT, onUpdate: dispatchDone});
			}
		}

		public function get target():Number
		{
			return _target;
		}

		public function dispatchDone():void
		{
			dispatchEvent(new Event(DONE));
		}

		public function Slot25Loading(r:* = null)
		{
			super(r);
		}
	}
}
